/**
 * Created with JetBrains PhpStorm.
 * User: jiangshuguang
 * Date: 14-10-20
 * Time: 下午4:32
 * To change this template use File | Settings | File Templates.
 */

exports.ShareTip = P.createUi({
    _data:{
        tip:'',
        autoclose:true,
        content:''
    },

    _create:function(){
        var $root = $('' +
            '<div class="ui-share-tip">' +
                '<div class="share-content">' +
                    '<div class="share-type attention">' +
                        '<span>点击关注</span>' +
                    '</div>' +
                    '<div class="share-type tofriend">' +
                        '<span>分享到微信群或者发送给朋友</span>' +
                    '</div>' +
                    '<div style="height: 5px;"></div>' +
                    '<div class="tip-content">'+this.data("content")+'</div>' +
                '</div>' +
            '</div>' +
            '').appendTo("body");
        this.data({
            '$root':$root
        })

    },

    _init:function(){
        var me = this;
        this.data('$root').on("click",function(){
            if(me.data('autoclose')){
                $(this).hide();
            }
        }).on('touchmove',function(e){
                e.preventDefault();
            })
    },

    notAutoClose:function(){
        this.data("autoclose",false);
    },

    _show:function(content){
        var $root = this.data("$root");
        $root.find('.share-type').hide();
        $root.find('.tip-content').text() || $root.find('.tip-content').hide();
        content && $root.find('.tip-content').html(content).show();
        $root.show();
    },

    showShare:function(content){
        this._show(content);
        this.data("$root").find('.tofriend').show();
    },

    showAttention:function(content){
        this._show(content);
        this.data("$root").find('.attention').show();
    },

    hide:function(){
       this.data("$root").hide();
    }
});